# Forked from Alpine to apply mobile adaptivity patches

pkgname=mutter-mobile
pkgver=46.1
pkgrel=1
pkgdesc="clutter-based window manager and compositor"
url="https://wiki.gnome.org/Projects/Mutter/"
# ricsv64: doesn't build currently:
# https://builds.sr.ht/~postmarketos/job/869829#task-pmbootstrap_build-1224
arch="all !riscv64"
license="GPL-2.0-or-later"
depends="
	gnome-settings-daemon-mobile
	gsettings-desktop-schemas
	mutter-mobile-schemas
	xkeyboard-config
	xwayland
	"
makedepends="
	at-spi2-core-dev
	cairo-dev
	dbus-dev
	elogind-dev
	eudev-dev
	fribidi-dev
	gdk-pixbuf-dev
	glib-dev
	gnome-desktop-dev
	gnome-settings-daemon-mobile-dev
	gobject-introspection-dev
	graphene-dev
	gtk+3.0-dev
	json-glib-dev
	lcms2-dev
	libcanberra-dev
	libdrm-dev
	libgudev-dev
	libice-dev
	libinput-dev
	libsm-dev
	libwacom-dev
	libx11-dev
	libxau-dev
	libxcb-dev
	libxcomposite-dev
	libxcursor-dev
	libxdamage-dev
	libxext-dev
	libxfixes-dev
	libxi-dev
	libxinerama-dev
	libxkbcommon-dev
	libxkbfile-dev
	libxrandr-dev
	libxrender-dev
	libxtst-dev
	libei-dev
	mesa-dev
	meson
	pango-dev
	pipewire-dev
	startup-notification-dev
	wayland-dev
	wayland-protocols
	xorg-server
	"
options="!check" # Can't be run with release builds
provides="mutter=$pkgver-r$pkgrel"
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-lang $pkgname-schemas::noarch"
_commit="46-mobile.1"
source="mutter-mobile-$_commit.tar.gz::https://gitlab.gnome.org/verdre/mutter-mobile/-/archive/$_commit/mutter-mobile-$_commit.tar.gz
	pcversion.patch
	"
builddir="$srcdir/mutter-mobile-$_commit"

prepare() {
	default_prepare

	sed -i "s/libmutter_api_version = '.*'/libmutter_api_version = '99'/g" meson.build
	# versions in the format "46-mobile.1" are considered invalid by pkg-config
	sed -i 's/\([0-9]\+\)-mobile\.\([0-9]\+\)/\1.\2/' meson.build
}

build() {
	abuild-meson \
		-Dudev=true \
		-Dnative_backend=true \
		-Dintrospection=true \
		-Dxwayland_path=/usr/bin/Xwayland \
		-Dremote_desktop=true \
		-Dprofiler=false \
		-Dtests=false \
		-Dinstalled_tests=false \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

schemas() {
	pkgdesc="Mutter schemas related files"
	provides="mutter-schemas=$pkgver-r$pkgrel"
	depends=""

	amove usr/share/glib-2.0/schemas
	amove usr/share/GConf/gsettings
	amove usr/share/gnome-control-center/keybindings
}

lang() {
	default_lang
	provides="mutter-lang=$pkgver-r$pkgrel"
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
210266238a9cf56b77e195559a2f99574de4a52b973bad7143a88f112730dd61ebf807e6644519998f39fe5ddbcb1bfd589d0d5167c92718953d5ad22eba2ae7  mutter-mobile-46-mobile.1.tar.gz
670927a5528f9fec4801b7dab8a377b7280c239acb1f7a9077647deef71119738deb958a94d4ce0a99d39b29eeab3b2505698f7d19b880bbcec9f5260202d3a6  pcversion.patch
"
